#include "widget.h"
#include "ui_widget.h"
#include <QButtonGroup>
#include <QString>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //使用QButtonGroup 对单选按钮进行分组
    QButtonGroup* group1 = new QButtonGroup(this);
    QButtonGroup* group2 = new QButtonGroup(this);
    QButtonGroup* group3 = new QButtonGroup(this);

    group1->addButton(ui->radioButton_1);
    group1->addButton(ui->radioButton_2);
    group1->addButton(ui->radioButton_3);

    group2->addButton(ui->radioButton_4);
    group2->addButton(ui->radioButton_5);
    group2->addButton(ui->radioButton_6);

    group3->addButton(ui->radioButton_7);
    group3->addButton(ui->radioButton_8);
    group3->addButton(ui->radioButton_9);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{

    QString result = "今天你的安排是: ";
    if(ui->checkBox_study->isChecked())
        result += ui->checkBox_study->text();
    if(ui->checkBox_game->isChecked())
        result += ui->checkBox_game->text();
    if(ui->checkBox_work->isChecked())
        result += ui->checkBox_work->text();

    ui->label->setText(result);
}
